<?php
	$checkSessionIdpage = $this->checkSessionIdpage;
	if($checkSessionIdpage == 0)
	{
		echo "<center style='color:#41BBDE; padding:20px 0px'>Chọn Page cần thao tác</center>";
	}
	else
	{
		$list_cart = $this->list_cart;
?>

    <div class="commonpage notborder product-page">
        <form action="" method="">
        	<div class="head">
    			<div class="search-div">
    				<div class="pull-left" style="margin-top: 5px;">
    					<span>Sắp xếp theo trạng thái đơn hàng</span>
    					<select onchange="filterStatusCart(this.value)" style="height:25px;">
                        <?php
                            $st = isset($_GET['st']) ? $_GET['st'] : "";
                        ?>
                            <option <?php echo ($st == "") ? "selected='selected'" : "" ?> value="">Xem tất cả</option>
                            <option <?php echo ($st == "-1") ? "selected='selected'" : "" ?> value="-1">Hủy ĐH</option>
                            <option <?php echo ($st == "0") ? "selected='selected'" : "" ?> value="0">Chưa đọc</option>
                            <option <?php echo ($st == "1") ? "selected='selected'" : "" ?> value="1">Chưa giao</option>
                            <option <?php echo ($st == "2") ? "selected='selected'" : "" ?> value="2">Đã giao</option>
                        </select>
    				</div>
    				<div class="btn-search">
    					<p class="search_product">
                        	<span>Tìm kiếm</span>
                        	<input onkeyup="searchOrder(event, this.value)" type="text" placeholder="Tìm kiếm" />
                        </p>
    				</div>
    			</div>
        	</div>
        	<table class="tbl-home" border="0" cellspacing="0" cellpadding="0">
        		<tr>
        			<th width="5%">Stt</th>
        			<th width="12%">Mã ĐH</th>
        			<th width="10%">Ngày đặt</th>
        			<th width="20%">Tên</th>
        			<th width="10%">SĐT</th>
        			<th width="20%">Email</th>
        			<th width="10%">Tình trạng</th>
        			<th width="20%">Công cụ</th>
        		</tr>
                <?php
                    $i = 1;
                    foreach($list_cart as $key=>$value)
                    {
                        $datecreate = strtotime(substr($value['date_create'], 0, 10));
                    	$datecreate =  date('d-m-Y', $datecreate);
                ?>
        		<tr>
            		<td><?php echo $i++ ?></td>
                    <td><?php echo $value['id_cart'] ?></td>
                    <td><?php echo $datecreate; ?></td>
            		<td style="text-align: left; padding:2px"><?php echo $value['name'] ?></td>
                    <td><?php echo $value['phone'] ?></td>
                    <td style="text-align: left; padding:2px"><?php echo $value['email'] ?></td>
                    <td>
                        <div style="position: relative;">
                            <?php
                                $st = "";
                                $status = "";
                                if($value['status'] == -1) {$st = "cancel"; $status = "Hủy ĐH";}
                                if($value['status'] == 0) {$st = "orange"; $status = "Chưa đọc";}
                                if($value['status'] == 1) {$st = "green"; $status = "Chưa giao";}
                                if($value['status'] == 2) {$st = "grey"; $status = "Đã giao";}
                            ?>
                            <p class="status_cart status_cart_<?php echo $value['id_cart']?> <?php echo $st ?>"><?php echo $status ?></p>
                            <select onchange="ChangeStCart('<?php echo $value['id_cart'] ?>', this.value, this.options[this.selectedIndex].text)" class="st_cart change_st_cart_<?php echo $value['id_cart'] ?>">
                                <option value="">Chọn</option>
                                <option value="-1">Hủy ĐH</option>
                                <option value="1">Chưa giao</option>
                                <option value="2">Đã giao</option>
                            </select>
                        </div>
                    </td>
                    <td align="center">
            			<a onclick="openChangeStCart('change_st_cart_<?php echo $value['id_cart'] ?>')" href="javascript:void(0)"><img title="Thay đổi trạng thái đơn hàng" alt="edit" src="<?php echo APP_DOMAIN . '/application/templates/giaodien_admin/images/pencil.png' ?>"/></a>
            			<a onclick="viewCart('<?php echo $value['id_cart'] ?>')" href="javascript:void(0)"><img title="Chi tiết đơn hàng" alt="detail" src="<?php echo APP_DOMAIN . '/application/templates/giaodien_admin/images/setting.png' ?>"/></a>
                        <a onclick="deleteCart('<?php echo $value['id_cart'] ?>')" href="javascript:;"><img title="Xóa đơn hàng" alt="del" src="<?php echo APP_DOMAIN . '/application/templates/giaodien_admin/images/delete.png' ?>"/></a>
            		</td>
            	</tr>
                <?php
                    }
                ?>
        	</table>
        <div class="clear"></div>
    </div>
<?php } ?>


















